const Router = require("koa-router")
const YBTool = require('@/lib/tool/YBTool')
const Path = require('path')

/**
 * 路由对象
 * @type {Router}
 */
const router = new Router()

/**
 * 获取JS主页
 */
router.get('/web', async function (ctx, next) {
  const filePath = YBTool.deviceType(ctx) ? 'pc.html' : 'm.html'
  ctx.sendHtmlFile(Path.resolve(__dirname, '../../view/web/', filePath))
})

/**
 * 获取TS主页
 */
router.get('/web-ts', async function (ctx, next) {
  const filePath = YBTool.deviceType(ctx) ? 'pc.html' : 'm.html'
  ctx.sendHtmlFile(Path.resolve(__dirname, '../../view/web_ts/', filePath))
})

/**
 * 获取react主页
 */
router.get('/web-react*', async function (ctx, next) {
  ctx.sendHtmlFile(Path.resolve(__dirname, '../../view/web-react/index.html'))
})

/**
 * 获取react主页
 */
router.get('/ant-design-pro*', async function (ctx, next) {
  ctx.sendHtmlFile(Path.resolve(__dirname, '../../view/ant-design-pro/index.html'))
})

/**
 * 获取react移动端主页
 */
router.get('/web-react-mobile*', async function (ctx, next) {
  ctx.sendHtmlFile(Path.resolve(__dirname, '../../view/web-react-mobile/index.html'))
})

module.exports = router
